home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / bbs / fnos16a5.zip / HELP.ZIP / EDITOR < prev    next >
Text File  |  1996-01-01  |  16KB  |  330 lines

  1.  
  2. editor <filename>
  3.  
  4.      Invoke an internal ASCII text editor.  One of two editors was
  5.      selected at compile time.  If ED was defined, a line-oriented
  6.      editor, similar to UN*X V7 ed, is invoked.  If instead TED was
  7.      defined, a full-screen editor similar to TED2 is invoked.
  8.      Note that <filename> may be too large to process.  The editor
  9.      is intended for sysops to edit small configuration files, such
  10.      as ftpusers, forward.bbs, etc.
  11.  
  12.      Ed requires about 13KB for code, and reads files into memory,
  13.      subject to available memory and the 'memory threshold' setting.
  14.      Ed is usable by remote sysops and works over linemode connections.
  15.      Ted needs 5KB of code space and will allocate two 8KB buffers,
  16.      thus the largest file it can process is 8192 bytes long.  Ted
  17.      can only be used from the local console.
  18.  
  19.      This file describes both editors, first ED and then TED.
  20.  
  21. ED:
  22.      As a line editor, ed operates in one of two modes: COMMAND
  23.      mode, in which a colon is displayed at the screen's bottom
  24.      to prompt for a command; and INPUT mode, in which all
  25.      keyboard input is added to the file (edit buffer). From
  26.      COMMAND mode, INPUT mode is entered by either the `i' or `a'
  27.      commands. From INPUT mode, the COMMAND mode is restored by
  28.      entering a line consisting of a single period by itself.  If
  29.      such a line is desired in the file, it can be created by
  30.      entering (for instance) two periods, then using the `s'
  31.      command to change these to only one period.
  32.  
  33.      A command consists of an optional line-range specification,
  34.      a single character indicating the command, and for some
  35.      commands an optional third argument.  The line-range
  36.      specification is either a single line number or a first-line
  37.      number and a last-line number separated by a comma.  The
  38.      character `^' means the first line of the file; `$' means
  39.      the last line of the file.
  40.  
  41.      Commands:
  42.      <newline>
  43.          If a line is specified, make that the new current line.
  44.          Otherwise advance the current-line-pointer by one line.
  45.      =   Print the line number of the current line.
  46.      .   (by itself)  Print the current line.
  47.      -   (by itself)  Move the current-line-pointer back one, and
  48.          print the new current line.
  49.      +   (by itself)  Move the current-line-pointer forward one, and
  50.          print the new current line.
  51.     \x   (by itself)  Go to line marked previously by kx (x in a..z)
  52.      /   (followed by search string)  Go to next line matching the
  53.          string. See Regular Expressions, below.
  54.      ?   (followed by search string)  Go to preceding line matching
  55.          the string. See Regular Expressions, below.
  56.      a   Go into INPUT mode with a new line following the current
  57.          line. (INPUT mode is terminated by an input line containing
  58.          only a period in the first column.)
  59.      i   Go into INPUT mode with a new line preceding the current
  60.          line. (INPUT mode is terminated by an input line containing
  61.          only a period in the first column.)
  62.      c   Delete the specified lines (or the current line) and then
  63.          add new lines in their place.  This is equivalent to a `d'
  64.          command followed by an `i' command.
  65.      d   Delete the specified range of lines (or the current line).
  66.          Leave the current-line-pointer at the following line.
  67.      e   Clear the edit buffer and begin editing a new file.  This
  68.          command fails if the buffer contains changes (or new lines)
  69.          which have not been written out.  To discard these changes
  70.          and edit a new file, use `E' instead of `e'.
  71.      E   Clear the edit buffer and begin editing a new file, regardless
  72.          of any changes to the current edit buffer.
  73.      f   Print the filename, or set it to a new name if specified.
  74. g/RE/c   Execute an arbitrary ed command "c" on each line in the given
  75.          line range, that matches Regular Expression RE.
  76.      j   Join the addressed lines together (or the current line to
  77.          the previous line).
  78.      k   Mark the addressed line with the specified letter.  Example:
  79.          `17ka' puts mark "a" on line 17.  See \ command.
  80.      l   List the addressed lines, showing all non-printing characters
  81.          and indicating the end-of-line.
  82.      m   Move the specified range of lines to follow the line number
  83.          given.  Example:  `5,7m3' moves lines 5 through 7 "up", to
  84.          follow line 3.
  85.    p,P   Print the specified lines.
  86.      q   Quit the editor.  This fails if the edit buffer contains
  87.          any changes.  If so, use `Q' instead.
  88.      Q   Quit the editor absolutely.  Any changes are discarded.
  89.      r   Read in a file, adding it after the current line.
  90.      s   Substitute text on the current line.  Example:  `s/alp/be/'
  91.          finds the string "alp" and replaces it with "be".  The
  92.          first string may contain Regular Expressions, see below.
  93.          If the replacement string contains an '&', the '&' is replaced
  94.          by that portion of the line text that matched the regular
  95.          expression.  If a '\d' (d in 1..9) is encountered in the
  96.          replacement string, it is replaced by that portion of the
  97.          line text matched by the d'th pair of parentheses in the
  98.          regular expression.
  99.          The replacement string may be followed by a delimiter and
  100.          two optional flags: "g" to indicate global replacement, ie,
  101.          every occurance is replaced, not just the first, and "p"
  102.          to print the result of the command's operation.
  103.    set   [opt].  Displays current options, or sets given option.
  104.          Options are: number     show line numbers
  105.                       nonumber   don't show line numbers (default)
  106.                       list       show HT as ^i, show $ at end-of-line
  107.                       nolist     show lines verbatim (default)
  108.                       eightbit   retain high-order bit in input data
  109.                                  (default)
  110.                       noeightbit strip off high-order bit
  111.      t   Transfer (copy) the specified range of lines to follow the
  112.          line number given.  Example:  `5,7t7' puts a copy of lines
  113.          5 through 7 after line 7.
  114. v/RE/c   Execute an arbitrary ed command "c" on each line in the given
  115.          line range, that does NOT match Regular Expression RE.
  116.    w,W   Write the edit buffer out.  If a filename is given, it is
  117.          used and becomes the current filename.  If a range of lines
  118.          is specified, only those lines are written.
  119.      x   Write the entire buffer out to its file, and terminate.   
  120.      z   Print a full screen.  Variants include:
  121.          z-   fill the screen, ending at current line
  122.          z.   fill the screen, centered about the current line
  123.          z+   fill the screen, beginning with the current line
  124.  
  125.  
  126.      BUGS and COMMENTS
  127.      Here's an example of how to split a line:  .s/BUGS/BU\nGS/
  128.      The backslash n (\n) ends the current line after the U and
  129.      starts another line beginning with G.
  130.  
  131.      Limited arithmetic is possible on line numbers or ranges.
  132.      For example:  .,.+10p     print current and following 10 lines
  133.                    .,+10p      same (dot is implicit)
  134.                    -5,+5p      print 11 lines centered on current line.
  135.               /n5knx/;+5p      find next occurance of "n5knx", make
  136.                                that the current line, then print it and
  137.                                the following 5 lines.
  138.  
  139.  
  140.      REGULAR EXPRESSIONS
  141.        Regular  expressions are the extended kind found in grep.
  142.        They are composed of characters as follows:
  143.  
  144.        c          matches the non-metacharacter c.
  145.  
  146.        \c         matches the literal character c.
  147.  
  148.        .          matches any character except newline.
  149.  
  150.        ^          matches the beginning of a line or a string.
  151.  
  152.        $          matches the end of a line or a string.
  153.  
  154.        [abc...]   character class, matches any of the  characters
  155.                   abc....  A range may be specified as x-y.
  156.  
  157.        [^abc...]  negated  character class, matches any character
  158.                   except abc...  and newline.
  159.  
  160.        r1|r2      alternation: matches either r1 or r2.
  161.  
  162.        r1r2       concatenation: matches r1, and then r2.
  163.  
  164.        r*         matches zero or more r's.
  165.  
  166.        \(r\)      grouping: matches r.
  167.  
  168.        The escape sequences that are valid  in  string  constants
  169.        are also legal in regular expressions, e.g., \t for tab.
  170.  
  171.        Example: s/^.*z/X/         Replace all characters through
  172.                                   the last z with a single X.
  173.                 s/[aA][aA]*/&x/g  Suffix all sequences of a or A
  174.                                   chars with an x.
  175.                 s/\(j\)\(j*\)\([^;])/\1Z\2\3/g  Insert a Z after
  176.                                   the first j in each sequence of
  177.                                   j's that is not followed by a
  178.                                   semicolon.
  179.  
  180.      AUTHORS
  181.      Brian Beattie seems to be the original author.  Kees Bot is
  182.      associated with it.  Allan Holub authored some bitmap code.
  183.      Andy Tanenbaum ported it to MINIX, and posted it to Usenet.
  184.      Bob Montante ported it to MSDOS and did some minor dressing-up.
  185.      Ed L. did further cleanups, and James Dugal ported it to Jnos
  186.      and made a few more fixes.
  187.  
  188. ----------------------------------------------------------------------
  189.  
  190. TED:
  191.      See the article "The tiniest editor you'll ever need" by Tom
  192.      Kihlken,  in the November 15, 1988 issue of PC Magazine for
  193.      more detail than is  presented here.  Portions of this text
  194.      are excerpted from that article.   The source listing,
  195.      itself, was copied directly from that article and  altered
  196.      as appropriate to add comments or change or improve the
  197.      program. Modifications are by James E. Galbraith, June 1989,
  198.      and adaption to Jnos by James Dugal, Dec 1995.
  199.  
  200.      TED follows normal text conventions: pressing the <Enter>
  201.      key actually  adds two characters, Carriage-return (ASCII
  202.      13) and Line-feed (ASCII 10),  also known as a "hard
  203.      carriage return".  The <Tab> key inserts the ASCII 9  tab
  204.      character, and advances the screen cursor to the next column
  205.      that is  an even multiple of eight.  The <Backspace> key
  206.      deletes the character to  its immediate left ("destructive"
  207.      backspace) and combines two lines if it  is pressed while in
  208.      the first column.
  209.  
  210.      Like DOS, TED lets you enter any character (except <Nul>,
  211.      value 00) by  holding down the Alt key, typing the decimal
  212.      value of its ASCII code on  the numeric keypad, then
  213.      releasing Alt.  This gives you access both to  nonprinting
  214.      codes below ASCII 32 and to the upper-order (ASCII 128 to
  215.      255)  characters in the extended IBM set.  TED2 allows the
  216.      <Nul> code to be  entered by pressing the <Shft-F1> key. 
  217.      Unassigned keyboard codes are treated as no-operations.
  218.  
  219.      WARNING: because the Jnos keyboard input routines are used,
  220.      the FKEY command must be used to define any editing key
  221.      before it can be used in TED.  A suggested set of fkey
  222.      commands can be found below.
  223.  
  224.      The TED Keypad commands are:
  225.      KEY                    DESCRIPTION
  226.      Up Arrow               Moves cursor up one row
  227.      Down Arrow             Moves cursor down one row
  228.      Left Arrow             Moves cursor left one column
  229.      Right Arrow            Moves cursor right one column
  230.      PgUp                   Moves text window up one page
  231.      PgDn                   Moves text window down one page
  232.      Home                   Moves cursor to start of row
  233.                                (if at home, next up)
  234.      End                    Moves cursor to end of row (if at end,
  235.                                next end down)
  236.      Ins                    Toggles insert/overstrike mode
  237.      Del                    Deletes character (right) at cursor
  238.                                (saved in UnDo)
  239.      Backspace              Deletes character (left) at cursor
  240.                                (not saved in UnDo)
  241.      Ctrl-PgUp              Does a PgUp, then a PgDn.
  242.      Ctrl-Home              Moves to top of file.
  243.      Ctrl-PgDn              Moves to bottom of file
  244.      Ctrl-End               Moves to bottom of file (alias)
  245. *    Ctrl-Right Arrow       Moves text window right eight columns
  246. *    Ctrl-Left Arrow        Moves text window left eight columns
  247.  
  248.  
  249.      The TED Editing Functions are:
  250.      KEY       FUNCTION        OPERATION
  251.      F1        Help            Help screen
  252.      ShftF1    <Nul>           Enters the <Nul> code (value 00)
  253.                                   in the file
  254.      F2        Exit            Save changes and exit (creates a
  255.                                   .BAK file)
  256.      ShftF2    Quit            Exit without saving changes
  257.      F3        Print           Prints the marked text
  258.      F4        Mark            Toggles mark state on/off
  259.      F5        Cut             Moves marked text to paste buffer
  260.      ShftF5    Paste           Inserts contents of paste buffer
  261.                                    (8K chars max)
  262.      F6        Search          Search for (case insensitive)
  263.                                    character string
  264.      ShftF6    Search Again    Search again for string
  265.      F7        UnDo            Replaces recently DELeted characters
  266.                                    (256 chars max)
  267.      ShftF7    Udel L          Inserts the last deleted line
  268.                                    (256 chars max)
  269.      F8        Del EOL         Deletes from cursor to the end of line
  270.      ShftF8    Del L           Deletes the current line
  271.  
  272.      Those marked with * are not directly available under Jnos.
  273.  
  274.      JNOS FKEY USAGE:
  275.      Because the Jnos keyboard handler does not pass key scancodes
  276.      we must make use of the Fkey command to redefine what Function
  277.      and editing keys send.  We do this by defining a two-byte
  278.      sequence: SOH and then the upper byte of the scancode (the lower
  279.      byte is zero for all editing and function keys we are interested
  280.      in).
  281.  
  282. # Source this file to program the console keys for the TED editor
  283. # Do F1 to F8
  284. fkey 59 "\001\073"
  285. fkey 60 "\001\074"
  286. fkey 61 "\001\075"
  287. fkey 62 "\001\076"
  288. fkey 63 "\001\077"
  289. fkey 64 "\001\100"
  290. fkey 65 "\001\101"
  291. fkey 66 "\001\102"
  292. # Now define Home,Up,PgUp,Left,Right,End,Down,PgDn,Ins,Del
  293. fkey 71 "\001\107"
  294. fkey 72 "\001\110"    *
  295. fkey 73 "\001\111"
  296. fkey 75 "\001\113"    *
  297. fkey 77 "\001\115"    *
  298. fkey 79 "\001\117"
  299. fkey 80 "\001\120"    *
  300. fkey 81 "\001\121"
  301. fkey 82 "\001\122"
  302. fkey 83 "\001\123"
  303. # Now Shifted F1..F3, F5..F8
  304. fkey 84 "\001\124"
  305. fkey 85 "\001\125"
  306. fkey 86 "\001\126"
  307. fkey 88 "\001\130"
  308. fkey 89 "\001\131"
  309. fkey 90 "\001\132"
  310. fkey 91 "\001\133"
  311. # Now do Control- Left,Right,End,PgDn,Home,PgUp
  312. #fkey 115 "\001\163"
  313. #fkey 116 "\001\164"
  314. fkey 117 "\001\165"
  315. fkey 118 "\001\166"
  316. fkey 119 "\001\167"
  317. fkey 132 "\001\204"
  318. # Let's use CF11,CF12 as Control-Left, Control-Right  so we don't have to
  319. # add new scancodes to the Jnos array in pc.c.
  320. fkey 137 "\001\163"
  321. fkey 138 "\001\164"
  322. # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  323. # The 4 cursor key redefinitions, marked with * above, will break telnet's
  324. # cursor key ansi emulation.  An alternative is to comment out the 4
  325. # redefinitons above, and use home/end to move vertically, and use F11/F12
  326. # as cursor left/right (which we now define):
  327. fkey 133 "\001\113"
  328. fkey 134 "\001\115"
  329.  
  330.